package com.bw.merchant.page

import android.os.Bundle
import android.util.Log
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.bw.base.path.RouterPath
import com.bw.common.view.BaseMvvmActivity
import com.bw.merchant.R
import com.bw.merchant.databinding.ActivityMerchantDetailBinding
import com.bw.merchant.vm.MerchantViewModel
import dagger.hilt.android.AndroidEntryPoint

/**
 * 企业详情页面
 */
@Route(path = RouterPath.PATH_MERCHANT_DETAIL_PATH)
@AndroidEntryPoint
class MerchantDetailActivity : BaseMvvmActivity<ActivityMerchantDetailBinding>() {
    @Autowired
    lateinit var aid:String
    override fun getLayoutId(): Int  = R.layout.activity_merchant_detail
    private val mViewModel:MerchantViewModel by viewModels()

    override fun initViews() {
        super.initViews()
        ARouter.getInstance().inject(this)
        Log.d("ssss","${aid}")
        mDataBinding.back.setOnClickListener {
            finish()
        }
        mViewModel.mMerchantDetailSuccess.observe(this){
            if (it.listed){
                mDataBinding.merchantDetailListed.setText("是")
            }else{
                mDataBinding.merchantDetailListed.setText("否")
            }
            mDataBinding.merchantDetailName.text = it.name
            mDataBinding.merchantDetailType.text = it.industryType
            mDataBinding.merchantDetailAddress.text = it.address
            mDataBinding.merchantDetailStockCode.text = it.stockCode
            mDataBinding.merchantDetailStockName.text = it.stockName
            mDataBinding.merchantDetailContactInfo.text = it.contactInfo
            mDataBinding.merchantDetailLegalRepresentative.text = it.legalRepresentative
            mDataBinding.merchantDetailStatus.text = it.status
        }

    }

    override fun loadData() {
        super.loadData()
        mViewModel.getMerchantDetailData(aid.toInt())
    }

}